Market position of first script is transferred to second:
first script:
public class Trade1 : Strategy
#region Variables
...
public static double MyProfit1;
public static double ExitAll;
#endregion
protected override void OnBarUpdate()
{
...
MyProfit1 = GetCurrentBid() - Position.AvgPrice;
if (MyExitAll==1) ExitLong(Position.Quantity);
}
second script:
public class Trade2 : Strategy
...
protected override void OnBarUpdate()
{
MyProfit2 = GetCurrentBid() - Position.AvgPrice;
...
if (Trade1.MyProfit1 + MyProfit2 >= targetProfit0 * TickSize)
{ExitShort(Position.Quantity); Trade1.MyExitAll=1;}
}
Any ideas? Wanted to know if it is correct to use global declarations like that? Does it work this way? Positions are getting opened but script doesn't want close them even if Target Profit is reached...
Any help is highly appreciated.
Comment