Tradeon error in algo

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #97669 quote
    richarjo
    Participant
    Senior

    Hi Robert Gozzi

    I have written the code (first attempt) and would appreciate it if you could advise whether correct or not. (it still comes up with the “tradeon” error.

    Here is the code:

    //————————————————————————- 					
    // Main code : wto32 								
    //————————————————————————- 					
    // Definition of code parameters 							
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated 			
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the “FLATBEFORE” time.
    DEFPARAM FLATBEFORE = 080000 							
    // Cancel all pending orders and close all positions at the “FLATAFTER” time 			
    DEFPARAM FLATAFTER = 165000 							
    										
    // Prevents the system from creating new orders to enter the market or increase position size before the specified time
    noEntryBeforeTime = 080000 								
    timeEnterBefore = time >= noEntryBeforeTime 						
    										
    // Prevents the system from placing new orders to enter the market or increase position size after the specified time
    noEntryAfterTime = 163000 								
    timeEnterAfter = time < noEntryAfterTime 						
    										
    // Prevents the system from placing new orders on specified days of the week 			
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0 				
    										
    ONCE WaitBars = 5 									
    ONCE TradeON = 1 //1=enable trading 0=disable trading 					
    ONCE Count = 0 //tallies bars as they elapse after a trade exits 				
    IF Count > 0 THEN 									
    Count = Count + 1 //tally bar after bar 							
    ENDIF 										
    IF Not OnMarket AND OnMarket[1] THEN //as soon as a trade exists start tallying 			
    Count = 1 //set counter to 1 to start tallying 						
    TradeON = 0 //disable trading 								
    ENDIF 										
    IF Count > WaitBars THEN //after desired number of bars elapsed reenable trading 			
    Count = 0 //clear counter 								
    TradeON = 1 //enable trading 								
    ENDIF 										
    										
    // Conditions to enter long positions 							
    ignored, ignored, ignored, ignored, ignored,  ignored, ignored, indicator1 = CALL “PRC_WaveTrend Oscillator”
    c1 = (indicator1 >= 0) 								
    indicator2 = ADX[14] 								
    c2 = (indicator2 >= 20) 								
    indicator3 = ExponentialAverage[5](close) 						
    c3 = (close >= indicator3) 								
    										
    IF (c1 AND c2 AND c3) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN 	
    BUY 2 CONTRACT AT MARKET 								
    ENDIF 										
    										
    // Conditions to exit long positions 							
    indicator4 = ExponentialAverage[5](close) 						
    c4 = (close <= indicator4) 								
    ignored, indicator5 = CALL “PRC_TAT”(close) 						
    c5 = (indicator5[1] <= indicator5) 							
    										
    IF c4 AND c5 THEN 									
    SELL AT MARKET 									
    ENDIF 										
    										
    ONCE WaitBars = 5 									
    ONCE TradeON = 1 //1=enable trading 0=disable trading 					
    ONCE Count = 0 //tallies bars as they elapse after a trade exits 				
    IF Count > 0 THEN 									
    Count = Count + 1 //tally bar after bar 							
    ENDIF 										
    IF Not OnMarket AND OnMarket[1] THEN //as soon as a trade exists start tallying 			
    Count = 1 //set counter to 1 to start tallying 						
    TradeON = 0 //disable trading 								
    ENDIF 										
    IF Count > WaitBars THEN //after desired number of bars elapsed reenable trading 			
    Count = 0 //clear counter 								
    TradeON = 1 //enable trading 								
    ENDIF 										
    										
    // Conditions to enter short positions 							
    indicator6 = ExponentialAverage[5](close) 						
    c6 = (close <= indicator6) 								
    indicator7 = ADX[14] 								
    c7 = (indicator7 >= 20) 								
    ignored, ignored, ignored, ignored, ignored, ignored, ignored, indicator8 = CALL “PRC_WaveTrend Oscillator”
    c8 = (indicator8 <=0) 									
    										
    IF (c6 AND c7 AND c8) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN 	
    SELLSHORT 2 CONTRACT AT MARKET 							
    ENDIF 										
    										
    // Conditions to exit short positions 							
    indicator9 = ExponentialAverage[5](close) 						
    c9 = (close >= indicator9) 								
    ignored, indicator10 = CALL “PRC_TAT”(close) 						
    c10 = (indicator10[1] <= indicator10) 							
    										
    IF c9 AND c10 THEN 									
    EXITSHORT AT MARKET 								
    ENDIF 										
    										
    // Stops and targets 									
    SET STOP pTRAILING 100

    Thank you in advance

    #97673 quote
    robertogozzi
    Moderator
    Master

    If you DO NOT use TradeON you will ALWAYS been reported the same error message.

    Replace line 45 with:

    IF (c1 AND c2 AND c3) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry AND TradeON THEN

    and line 82 with:

    IF (c6 AND c7 AND c8) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry AND TradeON THEN

    At lines 24 and 61 you can remove ONCE.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Tradeon error in algo


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
richarjo @richarjo Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
6 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/04/2019
Status: Active
Attachments: No files
Logo Logo
Loading...