New York, New York, United States
Experience: Beginner
Platform: TOS
Trading: Options
Posts: 53 since Jul 2015
Thanks Given: 13
Thanks Received: 7
|
Below is my code for Multicharts:
--
inputs: UpColor(Green), DnColor(Red), BarWidth(1) , CompBars(5) , start.time(0930) , end.time(1600);
vars: haClose(0), haOpen(0), color(0);
if BarNumber = 1 then
begin
haOpen = open;
haClose = (O+H+L+C)/4;
end;
if BarNumber > 1 then
begin
haClose = (O+H+L+C)/4;
haOpen = (haOpen [1] + haClose [1])/2 ;
end;
{ ................................................................................ }
if haClose > haOpen then color = UpColor
else color = DnColor;
for value1 = 1 to CompBars
begin
if haOpen <= MaxList(haOpen[value1],haClose[value1]) and
haOpen >= MinList(haOpen[value1],haClose[value1]) and
haClose <= MaxList(haOpen[value1],haClose[value1]) and
haClose >= MinList(haOpen[value1],haClose[value1]) then
color = color[value1];
end;
{ ................................................................................ }
{plotPB(haOpen,haClose,"heikin-ashi",color);
plotPB(High,Low,"heikin-ashi",color);
SetPlotWidth(1,BarWidth);
SetPlotColor(1,color);
end;}
{ ................................................................................ }
//initial beginning
If time >= start.time and time <= end.time and MarketPosition = 0 then begin
//long entry
if haClose > haOpen then begin
Buy 100 shares next bar at Market;
If MarketPosition = 1 and haClose < haOpen then begin
Sell ("close") 100 shares next bar at Market;
End;
end;
//short entry
if haClose < haOpen then begin
Sellshort ("enter short") 100 shares next bar at Market;
if MarketPosition = -1 and haClose > haOpen then begin
buytocover ("close") 100 shares next bar at Market;
end;
end;
End;
--
For some reason, the code isn't executing orders despite it being compiled successfully. If anyone can offer any help, it would be greatly appreciated.
Thank you.
|