MC: Simple strategy code problem / Easy Language - EasyLanguage Programming | futures io social day trading
futures io futures trading


MC: Simple strategy code problem / Easy Language
Updated: Views / Replies:4,297 / 4
Created: by true Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

MC: Simple strategy code problem / Easy Language

  #1 (permalink)
Elite Member
Germany
 
Futures Experience: Advanced
Platform: Ninjatrader,Tradestation,MultiCharts
Broker/Data: IB Esignal
Favorite Futures: TF,ES,GC,CL
 
Posts: 17 since Nov 2009
Thanks: 15 given, 6 received

MC: Simple strategy code problem / Easy Language

Hi all

These are my first try, with Easy Language.
My platform is Multicharts.

I fail, at a simple strategy.
I would like to send a stop and two targets for the broker,
if the first target is reached, will be break-even

Please take a look at the code.

many thanks.



 
Code
  
 //test
[IntrabarOrderGeneration=true]
 Inputs:
 Length(10),             //Averange
 contractsize (2),      //number of contracts
 target_0 ( 4 ),         //target_0 value 
 target_1 ( 8 ),         //target_1 value 
 breakeven ( 4 ),      //Breakeven 
 stoploss ( 11 );       //inital stoploss 
 
 variables:
   oneTick ( 0 ),
   RB (0),
   AvgRB ( 0 );
   
   oneTick = MinMove / PriceScale;     // calculate value of 1 tick.
   RB = Close - Open;
   AvgRB = Average(RB, Length);
   condition1 = AvgRB crosses over 0;
   condition2 = AvgRB crosses under 0;
   
   if MarketPosition = 0 then begin 
   if (condition1) then Buy contractsize Contracts next Bar At Close Limit; 
   if (condition2) then SellShort contractsize  Contracts next Bar At Close Limit;
 
   end;
   
   SetStopContract;
   SetStopLoss((stoploss * oneTick) * BigPointValue);                 //Stop set
   Setbreakeven(breakeven);                                                       //breakeven 


    SetExitOnClose;
    if time > 1530 and MarketPosition = 1 then Sell All Contracts This Bar At Close;
    if time > 1530 and MarketPosition = -1 then Buytocover All Contracts This Bar At Close;


   //Long Target
   if MarketPosition = 1 then begin
        Sell 1 Contract next bar At EntryPrice(0) + ((target_0) * oneTick) Limit;
        Sell 1 Contract next Bar At EntryPrice(0) + ((target_0+target_1)  * oneTick) Limit;
    end;
   
    //Short Target    
   if MarketPosition = -1 then begin
        Buytocover 1 Contract next Bar At EntryPrice(0) - ((target_0) * oneTick) Limit;
        Buytocover 1 Contract Next Bar At EntryPrice(0) - ((target_0+target_1) * oneTick) Limit;
    end;

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Frankfurt
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: FGBL 6E B4
 
max-td's Avatar
 
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 917 received


i am shure someone of the MC-guys takes a look at !

max-td
Reply With Quote
 
  #4 (permalink)
 Vendor: www.systemtradersuccess.com 
Gurnee, IL
 
Futures Experience: Advanced
Platform: TradeStation
Broker/Data: TradeStation
Favorite Futures: Futures
 
Posts: 46 since Apr 2010
Thanks: 17 given, 92 received

Please look this over and test it to see if this is what you were trying to do:

 
Code
//test
[IntrabarOrderGeneration=true]
 Inputs:
     Length(10),        //Averange
     numContracts (2),   //number of contracts
     target_0 ( 4 ),    //target_0 value in ticks
     target_1 ( 8 ),    //target_1 value in ticks
     breakeven ( 4 ),   //Breakeven in ticks
     stoploss ( 11 );   //inital stoploss in ticks
 
 variables:
    OneTickValue$(iff(GetExchangeName="FOREX", MinMove/PriceScale*BigPointValue*100000, MinMove/PriceScale*BigPointValue)),
    OneTickValue(iff(GetExchangeName="FOREX", MinMove/PriceScale*100000, MinMove/PriceScale)),
    intrabarpersist AvgRB( 0 );
   
    Once SetStopContract;    // Enable stop loss per ontract 
    SetExitOnClose;          // Close postion at end of session
   
    AvgRB = Average( C-O, Length );
       condition1 = AvgRB crosses over 0;
    condition2 = AvgRB crosses under 0;
   
    if ( MarketPosition = 0 ) then begin
    
        if (condition1) then Buy numContracts Contracts next Bar at Close Limit; 
        if (condition2) then SellShort numContracts  Contracts next Bar At Close Limit;
        
    end
    else begin
   
        SetStopLoss( stoploss * OneTickValue$ ); //Stop loss in dollars
        Setbreakeven( breakeven * OneTickValue$ ); //breakeven 
       
        if time > 1530 and MarketPosition = 1 then Sell All Contracts This Bar At Close;
        if time > 1530 and MarketPosition = -1 then Buytocover All Contracts This Bar At Close;
         
        //Long Target
       
        if ( MarketPosition = 1 ) then begin
        
            if ( CurrentContracts = numContracts ) then begin
                Sell("L1") 1 Contract next bar At EntryPrice + (target_0*OneTickValue) Limit;
                Sell("L2") 1 Contract next Bar At EntryPrice + (target_1*OneTickValue) Limit;
            end
            else Sell ("L2 ") 1 Contract next Bar At EntryPrice + (target_1*OneTickValue) Limit;
             
        end;
       
        //Short Target 
           
        if ( MarketPosition = -1 )  then begin
            if ( CurrentContracts = numContracts ) then begin
                Buytocover("S1") 1 Contract next Bar At EntryPrice - (target_0*OneTickValue) Limit;
                Buytocover("S2") 1 Contract Next Bar At EntryPrice - (target_1*OneTickValue) Limit;
            end
            else Buytocover("S2 ") 1 Contract Next Bar At EntryPrice - (target_1*OneTickValue) Limit;
       end;
       
end;

Reply With Quote
The following user says Thank You to Jeff65 for this post:
 
  #5 (permalink)
Elite Member
Germany
 
Futures Experience: Advanced
Platform: Ninjatrader,Tradestation,MultiCharts
Broker/Data: IB Esignal
Favorite Futures: TF,ES,GC,CL
 
Posts: 17 since Nov 2009
Thanks: 15 given, 6 received

@Jeff65

Many thanks for your help.
I have it tested today.
It works as it should.


thanks all

Reply With Quote

Reply



futures io > > > > > MC: Simple strategy code problem / Easy Language

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple M.A. Summing Code - Won't compile in MC bobbakerr EasyLanguage Programming 12 July 22nd, 2011 09:57 AM
easy language ..not easy... Serger EasyLanguage Programming 4 April 26th, 2011 04:42 PM
Easy Language for tradestation esam_jir EasyLanguage Programming 3 November 3rd, 2010 06:22 PM


All times are GMT -4. The time now is 12:08 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-12 in 0.09 seconds with 19 queries on phoenix via your IP 54.145.16.43