I'd like to create 2 GlobalVariable so that when my EA restarts it knows to use these two variables if they exist
The first is the value of a currency when an order (the first order) was placed, I call this variable center. It is the center value ie. Bid + Ask / 2 = center
The second is count ...Just a simple count that I increase by one with every new order.....until I close them all and the count is reset to zero.
//=======================================================
Will this work to check for Global Variables "center" and "count"....and if found write the values to the variables center and count in my EA?
if (GlobalVariableCheck(center))
if (GlobalVariableCheck(count))
{
center = (GlobalVariableGet(center));
count = (GlobalVariableGet(count));
AskStart=1;
BidStart=1;
}
//==============================================================
Will this (assuming AskStart and BidStart are zero) write the center value to the GlobalVariable "center"
if(AskStart==0)
if(BidStart==0)
{
AskStart = NormalizeDouble((Ask),4);
BidStart=NormalizeDouble((Bid),4);
center=((AskStart+BidStart)/2);
NormalizeDouble((center),4);
Print(center);
AskStart=1;
BidStart=1;
Comment(center);
GlobalVariableSet("center",center);
}
//=====================================================================
Will this write the value of count to GlobalVariable "count"?
tic = -1;
if(TradeLong)
if(center>(Ask+sh1))
if (count==1)
{
while((tic == -1 )&¢er>(Ask+sh1))
{
Sleep(4000);
RefreshRates();
tic = OrderSend(Symbol(),OP_BUY,LE1, NormalizeDouble((Ask),4),5,Ask-sl1*Point,0,"",255,0,CLR_NONE);
}
if (tic != -1)
{
count=2;
GlobalVariableSet("count", count);
tic = -1;
}
else
{
return(0);
}
while((tic == -1 )&¢er>(Ask+sh1))
{
Sleep(4000);
RefreshRates();
tic = OrderSend(Symbol(),OP_SELL,LE00, NormalizeDouble((Bid),4),5,Bid+sl0*Point,Bid-tp000*Point,"",255,0,CLR_NONE);
}
return(0);
}
//==============================================
Will this Delete GlobalVariable count and center??
if(OrdersTotal()==0)
{
Closenow=False;
count=1;
AskStart=0;
BidStart=0;
center=0;
Hedgeonce=1;
GlobalVariableDel(center);
GlobalVariableDel(count);
}
Thank you for your help and review.....
The first is the value of a currency when an order (the first order) was placed, I call this variable center. It is the center value ie. Bid + Ask / 2 = center
The second is count ...Just a simple count that I increase by one with every new order.....until I close them all and the count is reset to zero.
//=======================================================
Will this work to check for Global Variables "center" and "count"....and if found write the values to the variables center and count in my EA?
if (GlobalVariableCheck(center))
if (GlobalVariableCheck(count))
{
center = (GlobalVariableGet(center));
count = (GlobalVariableGet(count));
AskStart=1;
BidStart=1;
}
//==============================================================
Will this (assuming AskStart and BidStart are zero) write the center value to the GlobalVariable "center"
if(AskStart==0)
if(BidStart==0)
{
AskStart = NormalizeDouble((Ask),4);
BidStart=NormalizeDouble((Bid),4);
center=((AskStart+BidStart)/2);
NormalizeDouble((center),4);
Print(center);
AskStart=1;
BidStart=1;
Comment(center);
GlobalVariableSet("center",center);
}
//=====================================================================
Will this write the value of count to GlobalVariable "count"?
tic = -1;
if(TradeLong)
if(center>(Ask+sh1))
if (count==1)
{
while((tic == -1 )&¢er>(Ask+sh1))
{
Sleep(4000);
RefreshRates();
tic = OrderSend(Symbol(),OP_BUY,LE1, NormalizeDouble((Ask),4),5,Ask-sl1*Point,0,"",255,0,CLR_NONE);
}
if (tic != -1)
{
count=2;
GlobalVariableSet("count", count);
tic = -1;
}
else
{
return(0);
}
while((tic == -1 )&¢er>(Ask+sh1))
{
Sleep(4000);
RefreshRates();
tic = OrderSend(Symbol(),OP_SELL,LE00, NormalizeDouble((Bid),4),5,Bid+sl0*Point,Bid-tp000*Point,"",255,0,CLR_NONE);
}
return(0);
}
//==============================================
Will this Delete GlobalVariable count and center??
if(OrdersTotal()==0)
{
Closenow=False;
count=1;
AskStart=0;
BidStart=0;
center=0;
Hedgeonce=1;
GlobalVariableDel(center);
GlobalVariableDel(count);
}
Thank you for your help and review.....