NexusFi: Find Your Edge


Home Menu

 





Trading System to correct...


Discussion in EasyLanguage Programming

Updated
    1. trending_up 562 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 1 attachments




 
Search this Thread

Trading System to correct...

  #1 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

Hi,

I found this Trading System in my archive and I tried to test it but it only makes Long trades (Buy and Sell) and there is no Short;
there is probably some error in the code. If anyone can correct it, I thank you in advance:

----------------------------------------------------------------------------------------------------------------

Input: FastMA(9),SlowMA(26),MacdMA(4), NCOs(4), NBars(50), Trailbar(6);

Vars: MVal(0), MAvg(0), MDif(0), Counter(0), TotalBars(0), HighestHi(0), LowestLo(0);
Array: CO[2,50](0);

MVal = MACD(Close,FastMA,SlowMA);
MAvg = XAverage(MACD(Close,FastMA,SlowMA),MacdMA);
MDif = MVal - MAvg;

{ Store the MACD Cross information in the CO array }
If MDif Crosses Over 0 OR MDIF Crosses Under 0 Then Begin
For counter = 0 to 49 Begin
CO[ 0 , 50 - Counter ] = CO[ 0 , 49 - Counter ];
CO[ 1 , 50 - Counter ] = CO[ 1 , 49 - Counter ];
CO[ 2 , 50 - Counter ] = CO[ 2 , 49 - Counter ];
End;
CO[ 0 , 0 ] = BarNumber;
CO[ 1, 0 ] = High;
CO[ 2, 0 ] = Low;
End;

{ Find the Highest High and the Lowest Low of the cross over and under bars }
HighestHi = -1;
LowestLo = 9999;
For counter = 0 to NCOs-1 Begin
If CO[ 1 , counter ] > HighestHi then
HighestHi = CO[ 1 , counter ];
If CO[ 2 , counter ] < LowestLo then
LowestLo = CO[ 2 , counter ];
End;

{ If the last N crosses occured in the last 50 bars, then place the buy and sellshort orders }
Totalbars = BarNumber - CO[ 0 , NCOs - 1];
If TotalBars < NBars then Begin
Buy at HighestHi + Average(TrueRange,4)*.5 stop;
Sellshort at LowestLo - Average(TrueRange,4)*.5 stop;
End;

{ Trailing stop orders }
Sell next bar at Lowest( Low , TrailBar ) Stop;
Buytocover next bar at Highest( High , TrailBar ) Stop;

---------------------------------------------------------------------------------------------------------

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Cheap historycal L1 data for stocks
Stocks and ETFs
Quantum physics & Trading dynamics
The Elite Circle
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,666 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,360

Once I corrected the errors that prevented it from verifying, it takes long and short trades for me perfectly...



Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129



kevinkdog View Post
Once I corrected the errors that prevented it from verifying, it takes long and short trades for me perfectly...




Hi Kevin,


apart from: next bar to be added to: Buy and Sellshort (which will become: Buy next bar at HighestHi.....; Sellshort next bar at LowestLo....), the check turns out to be regular (see image); if you can explain me which errors you corrected, so the system will execute the Long and Short trades.
Thank you very much.

https://postimg.cc/zV5JXqSH

Reply With Quote
  #4 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,666 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,360

That is all I changed, and I get long and short trades. Tradestation Version 10

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

Hi Kevin,


I use Tradestation 8 and so that's probably what makes the difference.

Reply With Quote
Thanked by:




Last Updated on May 3, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts