What is wrong with my EasyLanguage (still learning)

Hello all!

First of all I’d like to say thank you to babypips.com and all the contributors for making this site such an excellent resource. It has really helped me out in learning the real basics so I have a great basis to build from.

I have jumped into writiing EasyLanguage but am having some problems. I’m not getting anything on my charts when I actually impliment the below. I’m sure as you read it you can tell its a simple trend following stratagy, but I need to get it working before I build in any complexity. If any one can fix it or at least point me in the direction on what is wrong, I would greatly appreciate it.

variables: 
fastMA(Average(close,18)), slowMA(Average(close,30));

if the fastMA > slowMA then begin
 
 	if close is > Highest(High,25) then buy at the open;
	
	if marketposition = 1 AND the close is < Lowest(Low,25)[1] then sell at next bar market;
	
	end;
		

	if the fastMA < slowMA then begin

	if the close is <= the Lowest(Low,25)[1] then sell at next bar market;

	if marketposition = -1 AND the Close is > Highest(High,25)[1] then buy at next bar market;

	end;

Many thanks!

Your syntax is a little off. A little too many mistakes for me to point them out one by one, so I’ll just write it how I would do it.

Input: fastLen (18),
         slowLen (30),
         scanPeriod (25); // Sets the lengths of the two MAs and period as external inputs for flexibility

Vars: fastMA (0), slowMA (0), highestH (0), lowestL (0);

fastMA = average(close, fastLen);
slowMA = average(close, slowLen);
highestH = Highest(high, scanPeriod);
lowestL = Lowest(low, scanPeriod);

Condition1 = fastMA > slowMA AND close > highestH[1]; //Long entry ("LE") condition
Condition2 = fastMA < slowMA and close < lowestL[1]; //Short entry ("SE") condition
Condition3 = close < lowestL[1]; //Long close ("LC") condition
Condition4 = close >  highestH[1]; //Short close ("SC") condition

//Entry Loop
if MarketPosition = 0 then begin
   if Condition1 then begin
      Buy ("LE") 1 contract next bar at Market;
   end;

   if Condition2 then begin
      SellShort ("SE") 1 contract next bar at Market;
   end;
end;

//Long Order Exit
if MarketPosition = 1 AND Condition3 then begin

   Sell ("LC") this bar on Close;

end;

//Short Order Exit
if MarketPosition = -1 AND Condition4 then begin

   BuyToCover ("SC") this bar on Close;

end;

Thank you for the quick reply. Since I’m new to this, I can sort of see what you have done here. It seems like you have abstracted things more than I have. I’m sure this is a much better way that I did it.

When I went to compile it I got a syntax error on the ==. My understanding is this is an operator that means “equal to”? I assumed this to be the case so I replaced it with = and it compiled successfully. I hope this is right?

I also cant manage to get it working successfully when I apply it to a chart. Other strategies I have created have worked, and after looking over what you wrote I can see anything wrong with it. Any insight would be greatly appreciated.

Oh crap, sorry, change those “==” to “=”. I forgot EL doesn’t differentiate between “=” and “==”. Sorry, too many different languages, I get confused sometimes.

Even after the changes, it was not loading?

EDIT: I have fixed the syntax error in my initial code.

EDIT2: Are you using TradeStation or MultiCharts?

I am using MultiCharts, would that make a difference? I have loaded other Signals and they do plot entries and exits on the chart so I’m assuming its not a configuration error my end.

It shouldn’t; I am using MC 64-Bit. I was just double checking.

I am just compiling the code right now, loading up some data. It may take 10-15 minutes, have a lot of data to load into RAM.

BTW, I had no problems compiling.

Same here, it compiled correctly for me too. I am loading 500 bars back, but I could load more. I also decreased the input values to try to get “anything” on the chart. Still no luck.

Working with DDE on 8.6GB of data for the GU… 25% done loading. I’ll let you know if it works on my end.

Okay, I fixed the code, in the initial post. Take a look. :slight_smile:

Awsome! All working now. Thanks for your help and going out of your way to help me, I really appreciate it. I hope other people are helped by the above code too.

No problem. Good luck with your system, seems like it still needs some work. :slight_smile: