Need Help with code - AmiBroker | futures io social day trading
futures io futures trading

Need Help with code
Updated: Views / Replies:1,393 / 3
Created: by sr114 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

Thread Tools Search this Thread

Need Help with code

  #1 (permalink)
Trading Apprentice
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: index,gold
Posts: 27 since Aug 2012
Thanks: 10 given, 1 received

Need Help with code

Hello Forum

this indi is based on the slope of tema of tema of the price and the entry and exit is based on the slope factorhat tema .

its working but need some rectification or fine tuning in the code. these are:

1. to lock the profit earned in an active trade (either long or short) [ set as 5% from the highest profit earned]

2. stoploss - to get protection from adverse situation. ( applied Applystoploss function]

this profit locking is the most important part - never intend to lose the profit earned . so a certain percentage must be locked or the trade reversed to take the profit from the board.

also the system will forcibly reverse an active trade at a predefined time

the profit calculation part - i like to get the profit calculation for the new day and not the continuation of the previous day trade and the profit calculation therein.

looking for the help

posting the code - pls help me to fine tune it by rectifying it

SetChartBkGradientFill( ParamColor("BgTop", colorBlack),
ParamColor("BgBottom", colorDarkGrey),ParamColor("TitleBack",colorBlack));
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));

SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);

grid_day = Day()!=Ref(Day(),-1);

messageboard =ParamToggle("Message Board","Show|Hide",0);

beginTradeTime= Param("Strt Time",091700,091500,151000,10);
endTradeTime= Param("End Time",151500,091500,151000,10);

EndDay = ParamTime( "No trade after ", "15:10:00" );
EndDay2 = ParamTime( "close position ", "15:10:00" );

tn = TimeNum();
dn = DateNum();
Exit = Ref( tn < EndDay2, -1 ) AND ( tn >= EndDay2 OR dn < Ref( dn, 1 ) );


_SECTION_BEGIN("trade system");

fact=U=Param("Main Curve Factor > 0",100,10,2000,1);
fact2=P=Param("Support Curve Factor..0-100",10,0,100,1);


Slptslow = (1000000*((tslow- Ref(tslow, -1))/tslow));

slptmonitor= (1000000*((tmonitor- Ref(tmonitor, -1))/tmonitor));

//Plot (tmonitor, "", colorGold, ParamStyle("Style"));
//Plot (tslow,"", colorWhite,ParamStyle(" Slope Style"));

Buy = Sell = Short = Cover = 0;

Buy = slptslow > fact AND Tn<EndDay;
Short = slptslow <-fact AND Tn<EndDay;

//Sell= ((Short) OR slptslow < ST ) OR exit; ;
//Cover= ((Buy) OR slptslow > ST ) OR exit;

Buysetup =Flip(Buy,Short);
Shortsetup =Flip(Short,Buy);

Sell = Shortsetup OR exit;
Cover = Buysetup OR exit;

ApplyStop(stopTypeTrailing ,2,Optimize( "max. profit stop level", 5, 2, 10, 1 ),1,False,0); // stop loss trailing of 5 % of the profit
ApplyStop(stopTypeLoss,stopModePercent,Optimize( "max. loss stop level", 5, 2, 10, 1 ),True,0);



BuyPrice = ValueWhen(Buy,BuyPrice1); bp=NumToStr(BuyPrice,1.2);
ShortPrice = ValueWhen(Short,shortPrice1); shp=NumToStr(ShortPrice,1.2);
SellPrice = ValueWhen(Sell,sellPrice1);
CoverPrice = ValueWhen(Cover,coverPrice1);



printf("\nBuy = " + NumToStr(Buy, 1.2) +
" Sell = " + NumToStr(Sell, 1.2) +
" Short = " + NumToStr(Short, 1.2) +
" Cover = " + NumToStr(Cover, 1.2) + "\n");

BuyInd = LastValue(Buy);
ShortInd = LastValue(Short);
SellInd = LastValue(Sell);
CoverInd = LastValue(Cover);

_TRACE("#, Indicators 2, Static, BuyInd = " + NumToStr(BuyInd,1.0) +
", SellInd = " + NumToStr(SellInd, 1.0) +
", ShortInd = " + NumToStr(ShortInd, 1.0) +
", CoverInd = " + NumToStr(CoverInd, 1.0) );*/

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorAqua, layer = 0,yposition = Low, offset = -10);
PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), colorRed, layer = 0, yposition = High, offset = -10);

PlotShapes( IIf(Cover, shapeHollowUpArrow,shapeNone), colorAqua, layer = 0,yposition = Low, offset = 10);
PlotShapes( IIf(Sell,shapeHollowDownArrow,shapeNone), colorPink, layer = 0, yposition = High, offset = -10);

//profit calculation
prf_ln= NumToStr((C-BuyPrice),1.2);
prf_sh= NumToStr((SellPrice-C),1.2);

//total equity calculation
firstTradeBarOfDay = TimeNum() >= beginTradeTime ;
firstTradeBarOfDay = firstTradeBarOfDay - Ref(firstTradeBarOfDay,-1);

inBuy1 = Flip(Buy,Sell);
inShort1 = Flip(Short,Cover);
totalPositions = IIf(inBuy1,1,0) * 1 + IIf(inShort1,-1,0) * 1;
actionAtBar = totalPositions - Ref(totalPositions,-1);

tc2 = TimeNum() >= beginTradeTime AND TimeNum() <= 151000;
eq1 = totalPositions * 1 * (C - Ref(C,-1));
eq2 = actionAtBar * 1 * (C - Ref(C,-1));
price_entry_exit = IIf(Buy,BuyPrice,IIf(Sell,SellPrice,IIf(Short,ShortPrice,IIf(Cover,CoverPrice,0))));
eq3 = actionAtBar * 1 * (C - price_entry_exit);
eqTotal = eq1 - eq2 + eq3 ;
rtEquity = tc2 * Sum(eqTotal,BarsSince(Ref(firstTradeBarOfDay,1) == 1));


_SECTION_BEGIN("msg brd");

(messageboard == 0 )
GfxSelectFont( "Tahoma", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectSolidBrush( colorDarkGrey );
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 230;
x = 5;
x2 = 230;
y = pxHeight;

GfxSelectPen( colorLightBlue, 1);
GfxRoundRect( x, y - 120, x2, y , 7, 7 ) ;

GfxTextOut( Name(), 13, y-105);
GfxTextOut( Date(), 13, y-85);

GfxTextOut( ("" + WriteIf (Long AND NOT Buy, "Long At : "+(BP) + "","")), 13, y-65);
GfxTextOut( ("" + WriteIf (Shrt AND NOT Short, "Short At : "+(ShP) + "","")), 13, y-65);

GfxTextOut( ("" + WriteIf (Long AND NOT Buy, "Current P/L : "+prf_ln+" / lot","")), 13, y-45);
GfxTextOut( ("" + WriteIf (Shrt AND NOT Short, "Current P/L : "+ prf_sh+" / lot","")), 13, y-45);
GfxTextOut("Total P/L Today = Rs. " + NumToStr((rtequity),1.2)+" / lot", 13 , y-25);



screen shots [ all time frame - 5 min - can also be reduced or range bars can be used ]

1. Scrip
Please register on to view futures trading content such as post attachment(s), image(s), and screenshot(s).

2. parameters of the indi
Please register on to view futures trading content such as post attachment(s), image(s), and screenshot(s).

3. another scrip [ same time frame - 5 min tf]
Please register on to view futures trading content such as post attachment(s), image(s), and screenshot(s).

regards and thanks

Last edited by sr114; August 17th, 2013 at 11:29 AM. Reason: addition of images
Reply With Quote
The following user says Thank You to sr114 for this post:
  #2 (permalink)
Trading Apprentice
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: index,gold
Posts: 27 since Aug 2012
Thanks: 10 given, 1 received


is the code posted here is wrong?
will it not work properly?

if so, where is the mistake?

waiting for the answer.


Reply With Quote
  #3 (permalink)
Trading Apprentice
Futures Experience: Intermediate
Platform: amibroker
Favorite Futures: index,gold
Posts: 27 since Aug 2012
Thanks: 10 given, 1 received


please close this thread

sorted out the problem - so no need to ask for the help

thanx and rgds

Reply With Quote
  #4 (permalink)
Trading Apprentice
tbilisi. Georgia
Futures Experience: None
Platform: Tradestation, MetaTrader
Favorite Futures: Futures
Posts: 5 since Apr 2014
Thanks: 0 given, 0 received

and what was problem?..

Reply With Quote


futures io > > > > Need Help with code

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Wyckoff Hunting for Great Risk/Reward Ratio w/Gary Fullett

Elite only

Digging into the Details of iSystems w/Stage 5 & iSystems

Jun 5

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can someone help me w/ this code calhawk01 NinjaTrader Programming 5 June 4th, 2013 08:42 PM
what does this code mean? ticker NinjaTrader Programming 2 April 11th, 2013 01:56 AM
need a coder to code new NT7 indi from existing MT4 indi - I have source code traderdp Hire a Consultant or Programmer 0 January 31st, 2013 08:21 PM
Better Momentum's "code #" I Lost...r all code #'s same ? xm4730 ?? Billbb Platforms and Indicators 2 January 26th, 2012 06:15 PM
Can someone code this ? skyfly NinjaTrader Programming 8 April 25th, 2011 12:40 PM

All times are GMT -4. The time now is 11:12 AM.

Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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 2018-05-21 in 0.12 seconds with 19 queries on phoenix via your IP