Here is the strategy ( see below pseudo code ) I want to develop and test. I can figure out most of the stuff but don't know how to
1 - track bought or sold- if addorder function succeeded or not
2 - if succeeded, how to extract the prices such as bought price or sold price.
3 - how to track the profit during testing of the strategy.
#buy at Market Open
if MarketOpen then
Buy 100 at next open price;
Purchase_Price = open price;
Bought = TRUE;
end if;
if ( close > Purchase_Price + 1) then
Sell 100 at next open price ;
Sold_price = open price;
Bought = False;
end if;
# Sell after Midday if not sold and price hasn't dropped more than 0.50
Midday = Noon Eastern;
If Midday and Bought = True then
if ( close > Purchase_price or close < Purchase_price -0.50 ) then
sell 100 at next open price;
Sold_price = open price;
Bought = False;
end if;
end if;
# Track total profit
total profit = total profit + ( Sold_Price - Purchase_Price ) *100;
1 - track bought or sold- if addorder function succeeded or not
2 - if succeeded, how to extract the prices such as bought price or sold price.
3 - how to track the profit during testing of the strategy.
#buy at Market Open
if MarketOpen then
Buy 100 at next open price;
Purchase_Price = open price;
Bought = TRUE;
end if;
if ( close > Purchase_Price + 1) then
Sell 100 at next open price ;
Sold_price = open price;
Bought = False;
end if;
# Sell after Midday if not sold and price hasn't dropped more than 0.50
Midday = Noon Eastern;
If Midday and Bought = True then
if ( close > Purchase_price or close < Purchase_price -0.50 ) then
sell 100 at next open price;
Sold_price = open price;
Bought = False;
end if;
end if;
# Track total profit
total profit = total profit + ( Sold_Price - Purchase_Price ) *100;