Thread: How to code?
View Single Post
  #784 (permalink)  
Old 03-25-2008, 11:04 PM
ShahJB's Avatar
ShahJB ShahJB is offline
Junior Member
 
Join Date: May 2007
Posts: 12
ShahJB is on a distinguished road
Quote:
Originally Posted by Beno View Post
Gidday ShahJB

I have seen global variables in code before but have had zero experience with them so yes i would like to accept your help to code this as its driving me nuts
i just coded the following promptly. Why don't u add this code first. Give it a try n pm me if it fails. I need to catch some sleep.

string val_old_string = "val_old" + Symbol();

int val_old = GlobalVariableGet(val_old_string);

if(val != val_old)
{
int pips_increment_decrement;
int current_total_pips;

string counter = "Pips Counter";
double pips_counter = GlobalVariableGet(counter);

if (val>val_old)
{
pips_increment_decrement = val - val_old;
current_total_pips = pips_increment_decrement + pips_counter;
GlobalVariableSet(counter, current_total_pips);
GlobalVariableSet(val_old_string, val);
}
else
{
pips_increment_decrement = val_old - val;
current_total_pips = pips_counter - pips_increment_decrement;
GlobalVariableSet(counter, current_total_pips);
GlobalVariableSet(val_old_string, val);
}
}
Reply With Quote