Coding Profit and Loss indicator , need help
Forums › ProRealTime forum Français › Support ProBuilder › Coding Profit and Loss indicator , need help
- This topic has 12 replies, 2 voices, and was last updated 8 years ago by Nicolas.
-
-
03/06/2016 at 12:50 AM #3437
A try to create an Earn & Loss’s indicator
I’m sorry for my bad english, i’ll do my best. Thanks for your understanding
By observing the curve Earnings(Gains) and losses of Prorealtime, I noticed..
– Earnings, it is only the price’ curve which evolve in hight direction , synchronized with a strategy,like a SellShort while the prices evolve in the low direction.
-Losses, it is only a price’symmetry on an axis X (wich must be identified), Buying while the prices evolve in the low direction.
I tried to coding into my thought. The result contains somes anomalies. I need your help to erase thoses anomalies
Best regardsBonjour
En observant la courbe Gains et pertes de Prorealtime, j’ai constaté..
– les gains, ce n’est que la courbe des prix qui évoluent à la hausse en synchronisation avec une strategie, (une strategie de VADE pendant que les prix evoluent à la baisse)
– les pertes, ce n’est que la symétrie des prix sur un axe X ( à identifier), desynchronisé avec une stratégie (une strategie d’ACHAT pendant que les prix évolue à la baisse).
J’ai tenté de coder dans le sens de cette reflexion. Le résultat comporte des anomalies. Je sollicite votre aide pour corriger les anomalies.Merci d’avance pour vos contributions
Bien à Vous1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556/// Exemple: strategie 1 //////////////////////stk=Stochastic[14,3](close)if stk crosses over 20 thenposition=1elsif stk crosses under 80 thenposition=-1else//position=undefinedendif/// Exemple : strategire 2 ////////////////////////c1=Average[7](close)//c2=Average[20](close)////if c1 crosses over c2 then//position=1//elsif c1 crosses under c2 then//position=-1//else////position=undefined//endif//**************************************************************************//// PROCEDURE ////**************************************************************************//GainsPertes=undefinedColor=undefined/////////////////////// ACHAT ///////////////////if position=1 thencpt=1Inversion=barindex // Mémorise le cours d'inversionGainsPertes=close[cpt] // ensuite je bloque dans cette section//*** couleur de la Position de la strategie : Vert pour la l'ACHAT ****Color=GainsPertes-(GainsPertes *0.01)///////////////////// VADE ///////////////////elsif position=-1 thencpt=(barindex-Inversion) // Nombre de jour depuis le l'InversionVarJ=(100-(close/close[cpt])*100) //GainsPertes=close[cpt] + (close[cpt]*VarJ/100)//*** couleur de la Position de la strategie : Rouge pour la VADE ****Color=GainsPertes+(GainsPertes *0.01)///////////////////// EXCEPTIONS///////////////////elseendif///////////////////// Finalement ///////////////////////////////RETURN GainsPertes as "Gains & Pertes",Color as " G & P Color"03/06/2016 at 1:29 AM #343903/06/2016 at 3:08 PM #3448Hello RicLg,
If you just want to have your profit and loss curve coloured by trade side (long or short), just use my adapted code below. It’s a quickly fix I made, i think that your curve problem came from a non-adapted use of the ‘couloured by’ instruction.
Here is how it looks now :
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556/// Exemple: strategie 1 //////////////////////stk=Stochastic[14,3](close)if stk crosses over 20 thenposition=1elsif stk crosses under 80 thenposition=-1else//position=undefinedendif/// Exemple : strategire 2 ////////////////////////c1=Average[7](close)//c2=Average[20](close)////if c1 crosses over c2 then//position=1//elsif c1 crosses under c2 then//position=-1//else////position=undefined//endif//**************************************************************************//// PROCEDURE ////**************************************************************************//GainsPertes=undefinedColor=undefined/////////////////////// ACHAT ///////////////////if position=1 thencpt=1Inversion=barindex // Mémorise le cours d'inversionGainsPertes=close[cpt] // ensuite je bloque dans cette section//*** couleur de la Position de la strategie : Vert pour la l'ACHAT ****//Color=GainsPertes-(GainsPertes *0.01)Color = 1///////////////////// VADE ///////////////////elsif position=-1 thencpt=(barindex-Inversion) // Nombre de jour depuis le l'InversionVarJ=(100-(close/close[cpt])*100) //GainsPertes=close[cpt] + (close[cpt]*VarJ/100)//*** couleur de la Position de la strategie : Rouge pour la VADE ****//Color=GainsPertes+(GainsPertes *0.01)Color = -1///////////////////// EXCEPTIONS///////////////////elseendif///////////////////// Finalement ///////////////////////////////RETURN GainsPertes coloured by Color as "Gains & Pertes"//,Color as " G & P Color"03/06/2016 at 4:28 PM #345003/06/2016 at 7:33 PM #3453You’re right, I think that the problem is that you store the candlestick Close at each new trade as the start of the next curve section. But you should use the last known value of the curve instead, because it is where your “profit and loss” curve may continue.
I’m currently trying to recode the whole thing in my own point of view, it gives me headache 🙂 Should not code at Sunday evening 🙂
03/06/2016 at 10:28 PM #345803/07/2016 at 8:46 AM #346503/07/2016 at 10:05 AM #3478Hello Ric, you can edit your post after it has been submitted, there are buttons just above your avatar. And yes this code would work for any timeframe, I dont see any restrictions that could make it not fully function in intraday! 🙂
03/07/2016 at 11:18 AM #348003/07/2016 at 12:59 PM #348303/07/2016 at 1:07 PM #348603/15/2016 at 4:16 PM #3811Bonjour,
Voici le code complet dans son état actuel, cela necessite quelques ajustements très certainement.
Merci pour vos suggestions et amélirations.
A bientôt
* En journalier – End of Day
* Pourriez-vous confirmez si cela fonctionne en intraday , s’il vous plait, Merci
* Could you confirm if the code will work in Intraday, thank you.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556/// Exemple : strategire 2 //////////////////c1=Average[7](close)c2=Average[20](close)if c1 crosses over c2 thenposition=1elsif c1 crosses under c2 thenposition=-1else//position=undefinedendif//**************************************************************************//// PROCEDURE ////**************************************************************************//closeMemoA=barindex //varJ=((100-(close/close[1])*100)*-1)/100 // Variation journalière 0.0145 (+1.45%)if barindex > 100 then // varier selon vos besoins/////////////////////// ACHAT ///////////////////if position=1 then//bloc=20prixInversion=close[closememoA-(closeMemoV)] // AxeGainsPertes=GainsPertes +( prixInversion*varj)//*** en invisible pour le remplissage ****ColorRemplissage=GainsPertes-(GainsPertes *0.02)color=1/////////////////// VADE ///////////////////elsif position=-1 then//bloc=10closeMemoA=closeMemoA[1]closememoV=barindexprixInversion=close[closememov-(closeMemoA+1)] // AxeGainsPertes=GainsPertes +( prixInversion*-varj)//*** en invisible pour le remplissage ****ColorRemplissage=GainsPertes+(GainsPertes *0.02)color=-1/////////////////// EXCEPTIONS ///////////////////else//bloc=1endifelse // barindexendif // Fin barindex///////////////////// Finalement ///////////////////////////////return GainsPertes coloured by color as "G&P Mb 7-20",ColorRemplissage as " G&P Remplissage"03/18/2016 at 4:56 PM #3963 -
AuthorPosts
Find exclusive trading pro-tools on