Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

Ptt5566

Help on Coding in Multicharts , Please....

Recommended Posts

Hello,

 

I am a newer trying to develop trading strategy , but the result is no good.

 

My coding is as follows:-

 

 

inputs: High_Length( 20),Low_Length( 20 ),add1(150),add2(300),add3(450),add4(600),stopProfit(50);

variables: var0( 0 ),var1( 0 ) ;

variables: kb(0),eb(0),es(0),kbarb(0),ks(0),kbars(0) ;

 

var0 = AverageFC( high, High_Length ) ;

var1 = AverageFC( low, Low_Length) ;

 

//============Condition=======================================

if high[1]>var0 and high>var0 and high[2]>var0 and high[1]>high and high[1]>high[2] then

value1=highest(high,3);

 

if low[1]<var1 and low<var1 and low[2]<var1 and low[1]<low and low[1]<low[2] then

value2=lowest(low,3);

 

//=============Entry/Exit=======================================

if close crosses over value1 and high>var0 and eb=0 then begin

buy next bar at market;

kb=close;

eb=1;

es=0;

kbarb=BarNumber;

end;

 

if close crosses under value2 and low<var1 and es=0 then begin

sellshort next bar at market;

ks=close;

es=1;

eb=0;

kbars=BarNumber;

end;

 

 

//=============Add Shares=====================================

//====buy

if marketposition*currentcontracts=1 then

buy("Add_Buy1") 1 shares next bar at kb+add1 stop;

 

if marketposition*currentcontracts=2 then

buy("Add_Buy2") 1 shares next bar at kb+add2 stop;

 

 

if marketposition*currentcontracts=3 then

buy("Add_Buy3") 1 shares next bar at kb+add3 stop;

 

 

if marketposition*currentcontracts=4 then

buy("Add_Buy4") 1 shares next bar at kb+add4 stop;

 

 

 

 

//====sell

 

if marketposition*currentcontracts=-1 then

sellshort("Add_Sell1") 1 shares next bar at ks-add1 stop;

 

if marketposition*currentcontracts=-2 then

sellshort("Add_Sell2") 1 shares next bar at ks-add2 stop;

 

if marketposition*currentcontracts=-3 then

sellshort("Add_Sell3") 1 shares next bar at ks-add3 stop;

 

if marketposition*currentcontracts=-4 then

sellshort("Add_Sell4") 1 shares next bar at ks-add4 stop;

 

 

 

 

//==============Exit Add========================

 

 

 

value11=BarNumber-kbarb;

value12=BarNumber-kbars;

 

value3=highest(high,barssinceentry )-stopProfit;

value4=lowest(low,barssinceentry)+stopProfit;

//print(kbarb,kbars);

 

if marketposition*currentcontracts>=2 then sell from entry("add_buy1") next bar at value3 Stop;

if marketposition*currentcontracts>=2 then sell from entry("add_buy2") next bar at value3 Stop;

if marketposition*currentcontracts>=2 then sell from entry("add_buy3") next bar at value3 Stop;

if marketposition*currentcontracts>=2 then sell from entry("add_buy4") next bar at value3 Stop;

 

 

if marketposition*currentcontracts<=-2 then buytocover from entry("Add_Sell1")next bar at value4 stop;

if marketposition*currentcontracts<=-2 then buytocover from entry("Add_Sell2")next bar at value4 stop;

if marketposition*currentcontracts<=-2 then buytocover from entry("Add_Sell3")next bar at value4 stop;

if marketposition*currentcontracts<=-2 then buytocover from entry("Add_Sell4")next bar at value4 stop;

 

 

When I exit add , there should be only one position(First entry/exit) in the market ,others all clear.

 

But the Add Shares Instruction is actioning again and again.

 

This bug how to fix ? please help me.

 

Thanks everyone in advance.

ptt5566.thumb.JPG.8e3cdb0ce3d3aaa6847f58c0220e7e7b.JPG

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Topics

  • Posts

    • Originally Answered: How can I compete with people who are better than me in every way?   So you want to outcompete people who are smarter, better looking and more experienced than you?   No problem!   All you have to do is outwork them.   Will Smith said, "if we both get on a treadmill either you're going to get off first or I'm going to die trying."     Most people just aren't willing to work that hard. Sure, they'll show up for the job interview and maybe practice in front of the mirror for a few minutes, but they won't do hours and hours of research and prepare for weeks. They won't wake up early and stay up late working on their dreams.   So while all those smart, good-looking, experienced people are waiting around for the next opportunity to come their way, you can outwork them and create your own opportunities.   In a few years, you'll be that "smart" person everyone looks up to. But you'll be different. You'll know it was your hard work, your inner strength and your commitment to living a great life that made you successful and brilliant - not luck or good genes.” – Tom Corson-Knowles, Quora Profits from free accurate cryptos signals: https://www.predictmag.com/   
    • @sxiqxx, Well done on making your first post a promising strategy. @everyone, post up if you want this coded into an EA. Although I switched to TradeStation, I still have an active MT5 demo with MetaEditor. I can code it without referencing object oriented programming which should be retroactively compatible with MT4. Let me know...
    • Please allow me to retort (in jest): RESPONSE 1 : Get a job supervising others where you're in control of performance reports and ride those others 100%. This makes your performance 100% with little to no effort.   RESPONSE 2: Feel free to piss off your boss but stay nonviolent. When the side effects of his viagra and testosterone boosters cause him to physically assault you, you have the legal upper hand. This can result in a boatload of trading capital.   RESPONSE 3: Feel free to have intimate relations with your boss if she finds you attractive. Rest assured that mum's the word because once again, you have the legal upper hand. This can also result in a boatload of trading capital.   RESPONSE 4: Don't be fake friends with any enemies... unless you need information from them. Being fake friends with everyone will cause you to become an empty shell of a person with no direction in life.   REPONSE 5: Get your boss to become reliant on your performance (really, just the performance of your subordinates), and then plan an "overheard" conversation wherein you fake an interview with another potential employer. You'll probably get a pay increase or a promotion.   RESPONSE 6: If you can give your 75% percent to a project, give 50% and rely on your legal upper hand(s). Learn to write trading algo's during your other 50%.   RESPONSE 7: Take all of the office boys out to nightclub where you merely sip soft drinks on a weeknight. Upon your return to the office in the morning, inform the security guards that all of the office boys are intoxicated. Your boss will love you for it.   RESPONSE 8: Never try to prove your client wrong or find faults in their processes, but do secretly collect their information in case you jump ship or "someone you know" decides to start his own company.   RESPONSE 9: Never stay in a firm for too long. Instead, use your ill-gotten capital to exit the rat-race and start trading.   RESPONSE 10: Trading pays more than your career. Interpersonal skills are now irrelevant. Use your technical skills for trading. Never stop learning and keep updating your technical skills.😁
    • There are a lot of trading strategies like elliot waves, wyckoff etc so we need to apply those who best suited to our need and are understandable too.
    • Scalping can be good during the high volatile markets however the new traders should be careful while entering and exiting the markets too quickly since they can make losses as well. If the broker support news trading we can make most out of the scalping in my opinion.  
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.